package com.example.neteasemusic

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.MotionEvent
import android.widget.Toast
import cn.bmob.v3.BmobSMS
import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.QueryListener
import cn.bmob.v3.listener.UpdateListener
import com.example.login.LoginActivity

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        //app -> Login  -> Logger
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        if (event?.action == MotionEvent.ACTION_DOWN){
            verify("")
            //qury
        }
        return true
    }
     fun qury(){
         BmobSMS.requestSMSCode("18313158463","",object:QueryListener<Int>(){
             override fun done(p0:Int?,p1:BmobException?) {
                 if(p1==null){
                     Toast.makeText(this@MainActivity,"短信发送成功:$p0",Toast.LENGTH_LONG).show()
                 }else{
                     Toast.makeText(this@MainActivity,"短信发送失败：$p1",Toast.LENGTH_LONG).show()
                 }
             }
         }
         )
     }

    fun verify(code:String){
        BmobSMS.verifySmsCode("18313158463","",object:UpdateListener(){
            override fun done(p0:BmobException?) {
                if(p0==null){
                    Toast.makeText(this@MainActivity,"短信发送成功:$p0",Toast.LENGTH_LONG).show()
                }else{
                    Toast.makeText(this@MainActivity,"短信发送失败：$p0",Toast.LENGTH_LONG).show()
                }
            }
        })
    }
}